<%@ page pageEncoding="UTF-8"%>
<%@ include file="../common/header.jsp"%>
<%@ include file="../common/nav.jsp"%>
<div class="panel panel-default" id="content">
	<div class="panel-heading">
        <h3 class="panel-title">类目维护</h3>
    </div>
    <div class="panel-body">
       <div class="row">
		  <div class="col-md-2">
		       <ul id="ztree-kind" class="ztree"></ul>
		  </div>
		  <div class="col-md-10" id="ztree-form-data"></div>
		</div>
    </div>
</div>
<script>
//完成ztree树的初始化
$.getJSON("${ctx}/category?opt=tree",function(result){
	$.fn.zTree.init($("#ztree-kind"), {
		data: {
			simpleData: {
				enable: true,
				idKey: "id",
				pIdKey: "parentId"
			}
		},
		callback: {
			onClick: function(e,treeId, treeNode){
				//阻止表单提交的默认事件
				e.preventDefault();
				//alert(treeNode.id);
				$('#ztree-form-data').load('${ctx}/category?opt=list&parentId='+treeNode.id);
			}
		}
	}, result.data);
});
//完成表的初始化
$('#ztree-form-data').load('${ctx}/category?opt=list');
</script>